/*
 * Copyright 2016 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.agerasample.basicsample;

import com.google.agera.BaseObservable;
import com.google.agera.Updatable;
import com.google.agera.UpdateDispatcher;

import ohos.agp.components.Component;

/**
 * This implements {@link Component.ClickedListener} so it can be attached to a
 * {@link Component}. It also extends {@link BaseObservable} so changes in here can be
 * passed on to its observer (ie an {@link Updatable}, using an {@link UpdateDispatcher}.
 */
public class OnClickObservable extends BaseObservable implements Component.ClickedListener {
    /**
     * Triggered when the associated {@link Component} is clicked by the user. The event
     * is passed on to the observers, using the {@link UpdateDispatcher} provided by {@link
     * BaseObservable}.
     *
     * @param component Component
     */
    @Override
    public void onClick(Component component) {
        dispatchUpdate();
    }
}
